home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Mindy / Mindy 1.2 - portable sources / comp / header.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-15  |  2.0 KB  |  67 lines  |  [TEXT/ttxt]

  1. /**********************************************************************\
  2. *
  3. *  Copyright (c) 1994  Carnegie Mellon University
  4. *  All rights reserved.
  5. *  
  6. *  Use and copying of this software and preparation of derivative
  7. *  works based on this software are permitted, including commercial
  8. *  use, provided that the following conditions are observed:
  9. *  
  10. *  1. This copyright notice must be retained in full on any copies
  11. *     and on appropriate parts of any derivative works.
  12. *  2. Documentation (paper or online) accompanying any system that
  13. *     incorporates this software, or any part of it, must acknowledge
  14. *     the contribution of the Gwydion Project at Carnegie Mellon
  15. *     University.
  16. *  
  17. *  This software is made available "as is".  Neither the authors nor
  18. *  Carnegie Mellon University make any warranty about the software,
  19. *  its performance, or its conformity to any specification.
  20. *  
  21. *  Bug reports, questions, comments, and suggestions should be sent by
  22. *  E-mail to the Internet address "gwydion-bugs@cs.cmu.edu".
  23. *
  24. ***********************************************************************
  25. *
  26. * $Header: header.c,v 1.4 94/10/05 20:55:03 nkramer Exp $
  27. *
  28. * This file deals with the file headers.
  29. *
  30. \**********************************************************************/
  31.  
  32. #include "../compat/std-c.h"
  33.  
  34. #include "mindycomp.h"
  35. #include "header.h"
  36.  
  37. struct header_handler {
  38.     char *key;
  39.     void (*func)(char *value);
  40.     struct header_handler *next;
  41. };
  42.  
  43. static struct header_handler *handlers = NULL;
  44.  
  45. void add_header_handler(char *key, void (*func)(char *value))
  46. {
  47.     struct header_handler *new = malloc(sizeof(struct header_handler));
  48.  
  49.     new->key = key;
  50.     new->func = func;
  51.     new->next = handlers;
  52.     handlers = new;
  53. }
  54.  
  55. void process_header(char *key, char *value)
  56. {
  57.     struct header_handler *handler;
  58.  
  59.     for (handler = handlers; handler != NULL; handler = handler->next) {
  60.     if (handler->key == key
  61.      || (handler->key != NULL && strcasecmp(key, handler->key) == 0)) {
  62.         (*handler->func)(value);
  63.         return;
  64.     }
  65.     }
  66. }
  67.